﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Parabola
{
    public partial class Table : Form
    {
        private Label[] xlabels = new Label[23], ylabels = new Label[23];
        public Dictionary<double, double> listitems;
        public string function;
        public int start, end;
        int xpoint, ypoint;

        public Table(int x, int y)
        {
            InitializeComponent();
            xpoint = x;
            ypoint = y;
        }

        private void Table_Load(object sender, EventArgs e)
        {
            #region Labellist
            xlabels[0] = lblx0;
            xlabels[1] = lblx1;
            xlabels[2] = lblx2;
            xlabels[3] = lblx3;
            xlabels[4] = lblx4;
            xlabels[5] = lblx5;
            xlabels[6] = lblx6;
            xlabels[7] = lblx7;
            xlabels[8] = lblx8;
            xlabels[9] = lblx9;
            xlabels[10] = lblx10;
            xlabels[11] = lblx11;
            xlabels[12] = lblx12;
            xlabels[13] = lblx13;
            xlabels[14] = lblx14;
            xlabels[15] = lblx15;
            xlabels[16] = lblx16;
            xlabels[17] = lblx17;
            xlabels[18] = lblx18;
            xlabels[19] = lblx19;
            xlabels[20] = lblx20;
            xlabels[21] = lblx21;
            xlabels[22] = lblx22;
            ylabels[0] = lbly0;
            ylabels[1] = lbly1;
            ylabels[2] = lbly2;
            ylabels[3] = lbly3;
            ylabels[4] = lbly4;
            ylabels[5] = lbly5;
            ylabels[6] = lbly6;
            ylabels[7] = lbly7;
            ylabels[8] = lbly8;
            ylabels[9] = lbly9;
            ylabels[10] = lbly10;
            ylabels[11] = lbly11;
            ylabels[12] = lbly12;
            ylabels[13] = lbly13;
            ylabels[14] = lbly14;
            ylabels[15] = lbly15;
            ylabels[16] = lbly16;
            ylabels[17] = lbly17;
            ylabels[18] = lbly18;
            ylabels[19] = lbly19;
            ylabels[20] = lbly20;
            ylabels[21] = lbly21;
            ylabels[22] = lbly22;
        #endregion
            this.Location = new Point(xpoint, ypoint);
            lblFunction.Text = function;
            for (int i=0; i<23; i++)
            {
                if (i <= listitems.Count - 1)
                {
                    xlabels[i].Text = Convert.ToString(listitems.Keys.ToArray()[i]);
                    if (double.IsNaN(listitems.Values.ToArray()[i])) ylabels[i].Text = "n/a";
                    else ylabels[i].Text = Convert.ToString(listitems.Values.ToArray()[i]);
                }
                else
                {
                    xlabels[i].Text = "";
                    ylabels[i].Text = "";
                }
            }
        }
    }
}
